package com.turing.post.transaction.util;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;

import com.turing.post.util.PCPSUtil;

/**
 * 商户交易附加卡详细信息
 * 
 * @author 李治
 * 
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "MCHADDCARDDETAIL")
@IdClass(MchAddCardDetail.class)
public class MchAddCardDetail implements Serializable {
	/**
	 * 商户ID
	 */
	private String merchantNo;  
	/**
	 * 帐务日期
	 */
	private Date tranDate;  
	/**
	 *  流水号
	 */
	private String tranSeqNo; 
	/**
	 *  卡号
	 */
	private String cardNo; 
	/**
	 *  交易金额
	 */
	private BigInteger amount; 

	public MchAddCardDetail() {
		super();
	}

	public MchAddCardDetail(String merchantNo, Date tranDate, String tranSeqNo,
			String cardNo, BigInteger amount) {
		super();
		this.merchantNo = merchantNo;
		this.tranDate = tranDate;
		this.tranSeqNo = tranSeqNo;
		this.cardNo = cardNo;
		this.amount = amount;
	}

	@Id
	@Column(name = "MERCHANTNO", nullable = false)
	public String getMerchantNo() {
		return merchantNo;
	}

	public void setMerchantNo(String merchantNo) {
		this.merchantNo = merchantNo;
	}

	@Id
	@Column(name = "TRANDATE", nullable = false)
	public Date getTranDate() {
		return tranDate;
	}

	public void setTranDate(Date tranDate) {
		this.tranDate = tranDate;
	}

	@Id
	@Column(name = "TRANSEQNO", nullable = false)
	public String getTranSeqNo() {
		return tranSeqNo;
	}

	public void setTranSeqNo(String tranSeqNo) {
		this.tranSeqNo = tranSeqNo;
	}

	@Id
	@Column(name = "CARDNO", nullable = false)
	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	@Column(name = "AMOUNT", nullable = false)
	public BigInteger getAmount() {
		return amount;
	}

	public void setAmount(BigInteger amount) {
		this.amount = amount;
	}

	@Override
	public int hashCode() {
		return PCPSUtil.getObjectListHashCode(new Object[] { getMerchantNo(),
				getTranDate(), getTranSeqNo(), getCardNo() });
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof MchAddCardDetail))
			return false;
		MchAddCardDetail other = (MchAddCardDetail) obj;
		if (!PCPSUtil
				.compareObject(this.getMerchantNo(), other.getMerchantNo()))
			return false;
		if (!PCPSUtil.compareObject(this.getTranDate(), other.getTranDate()))
			return false;
		if (!PCPSUtil.compareObject(this.getTranSeqNo(), other.getTranSeqNo()))
			return false;
		return PCPSUtil
				.compareObject(this.getCardNo(), other.getCardNo());
	}
}
